<template>
  <div class="index">
    <el-container class="index-con">
      <el-aside
        :class="showclass"
        style="width: 10%; overflow-x: hidden; position: fixed"
      >
        <leftnav></leftnav>
      </el-aside>
      <el-container class="main-con">
        <div class="width"></div>
        <div class="cantent">
          <el-header class="index-header">
            <navcon @dataAdd="dataAdd"></navcon>
          </el-header>
          <!-- <el-main class="partition"></el-main> -->
          <el-main class="index-main">
            <router-view :key="$route.path + $route.query.t"></router-view>
          </el-main>
          <contacts ref="contacts" :start="0"></contacts>
          <followup ref="followup" :start="0"></followup>
        </div>
      </el-container>
    </el-container>
  </div>
</template>
<script>
// 导入组件
import navcon from "../components/navcon.vue";
import leftnav from "../components/leftnav.vue";
import contacts from "../views/pageWorld/addCustomerData.vue";
import followup from "../views/pageWorld/addFollowUp.vue";
export default {
  name: "index",
  data() {
    return {
      showclass: "asideshow",
      showtype: false,
    };
  },
  // 注册组件
  components: {
    navcon,
    leftnav,
    contacts,
    followup,
  },
  methods: {
    // 新增联系人/新增跟进信息
    dataAdd(obj) {
      if (obj == 0) {
        // 新增联系人
        this.$refs.contacts.drawer = true;
      } else {
        // 新增跟进信息
        this.$refs.followup.drawer = true;
      }
    },
  },
  created() {
    // 监听
    this.$root.Bus.$on("toggle", (value) => {
      if (value) {
        this.showclass = "asideshow";
      } else {
        setTimeout(() => {
          this.showclass = "aside";
        }, 300);
      }
    });
  },
  beforeUpdate() {},
  // 挂载前状态(里面是操作)
  beforeMount() {},
};
</script>
<style >
.cantent {
  width: 90%;
  min-width: 670px;
  display: flex;
  flex-direction: column;
}
.index {
  background-color: #f2f2f2;
  width: 100%;
}
.index-con {
  height: 100%;
  width: 100%;
  box-sizing: border-box;
}
.index-main {
  /* padding: 0 20px 0 20px; */
}
.aside {
  width: 64px !important;
  height: 100%;
  background-color: #334157;
  margin: 0px;
}
.partition {
  padding: 0;
  margin: 0;
  width: 100%;
  height: 20px;
  background-color: #f2f2f2;
}
.asideshow {
  min-width: 200px;
  height: 100vh;
  background-color: #0276fe;
  margin: 0px;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1100;
}
.main-con {
  width: 100%;
  display: flex;
}
.width {
  width: 10%;
  min-width: 200px;
  height: 100vh;
  float: left;
}
/* 用户栏吸顶 */
.index-header {
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}
.el-main {
  padding: 0;
}
</style>
